
root=Node()
axes = Node(root)
axes.Load("axes.osg")
axes.SetScale(10,10,10)
cow =Node(root)
cow.Load("cow.osg")

title=Text(root,"ciao")
title.SetAlign(CENTER_CENTER)
title.SetPosition(0,430)

viewer.SetRoot(root)    
    
#---------------------------------    
def cp():
    print "cp = CameraPose", cm.GetPose().Repr()
    
#---------------------------------    

# 1) --- espressione invece di Valore 0
# 2) --- 

def slide1():
    
    cp  = cm.GetPose()
    cp0 = CameraPose(4.5, 4.5, 4.5, 56, 90, 1, 0, 0)
    cp1 = CameraPose(0, 0, 4, 50, 95, 1, 0, 0)
    cp2 = CameraPose(-0.4, -30, 0.5, 18, 90, 1, 0, 0)
    
    am.clear()

    Anim(0,0.5, title.SetPosition, Vec(0,430,0), Vec(0,500,0)  )
    Call(1,     title.SetText,     "this is slide 1" )
    Anim(1,0.5, title.SetPosition, Vec(0,500,0), Vec(0,430,0)  )
    Anim(0,2,   cm.SetPose, cp, cp2  )

    T0 = T
    Call(T0,   cow.SetPosition,   Vec(0,0,0) )
    Call(T0,   cow.SetRotation,   Quat(0,1,0,0) )
    Call(T0,   cow.SetScale,      Vec(1,1,1) )

    T0 = T+1
    Anim(T0,2, cow.SetRotation,   Quat(), Quat(-90,0,0,1)  )
    Anim(T0,2, cow.SetPosition,   Vec(0,0,0),  Vec(0,-30,0) )

    T0 = T+1
    Anim(T0,2, cow.SetRotation,   Quat(-90,0,0,1), Quat() )
    Anim(T0,2, cow.SetPosition,   Vec(0,-30,0), Vec(0,0,0) )

    am.play()
    
def slide2():
    cp  = cm.GetPose()
    cp0 = CameraPose(4.5, 4.5, 4.5, 56, 90, 1, 0, 0)

    am.clear()

    Anim(0,0.5, title.SetPosition, Vec(0,430,0), Vec(0,500,0)  )
    Call(1,     title.SetText,     "this is slide 1" )
    Anim(1,0.5, title.SetPosition, Vec(0,500,0), Vec(0,430,0)  )
    Anim(0,2,   cm.SetPose, cp, cp0  )

    T0 = T
    Call(T0,   cow.SetPosition,   Vec(0,0,0) )
    Call(T0,   cow.SetRotation,   Quat(0,1,0,0) )
    Call(T0,   cow.SetScale,      Vec(1,1,1) )

    T0 = T+1
    Anim(T0,2, cow.SetRotation,   Quat(), Quat(-90,0,0,1)  )
    Anim(T0,2, cow.SetPosition,   Vec(0,0,0),  Vec(0,-30,0) )

    T0 = T+1
    Anim(T0,2, cow.SetRotation,   Quat(-90,0,0,1), Quat() )
    Anim(T0,2, cow.SetPosition,   Vec(0,-30,0), Vec(0,0,0) )

    am.play()

#---------------------------------    
slides = [
  ("slide1",slide1),
  ("slide2",slide2),
]


